package com.xw.controller;


import com.xw.entity.Contact;
import com.xw.service.IContactService;
import com.xw.vo.ResultVO;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author y
 * @since 2021-09-15
 */
@RestController
@RequestMapping("/contact")
public class ContactController {

    private final IContactService contactService;

    public ContactController(IContactService contactService) {
        this.contactService = contactService;
    }

    /**
     * 添加联系人
     *
     * @param contact
     * @return
     */
    @PostMapping("/addContact")
    public ResultVO addContact(Contact contact) {
        return contactService.addContact(contact);
    }

    /**
     * 修改联系人
     *
     * @param contact
     * @return
     */
    @PostMapping("/updContact")
    public ResultVO updContact(Contact contact) {
        return contactService.updContact(contact);
    }

    /**
     * 查询联系人一个
     *
     * @param recordId
     * @return
     */
    @GetMapping("/findContact")
    public ResultVO findContact(@RequestParam("recordId") String recordId) {
        return contactService.findContact(recordId);
    }

    /**
     * 查询用户下联系人所有
     *
     * @param openId
     * @return
     */
    @GetMapping("/findContactList")
    public ResultVO findContactList(@RequestParam("openId") String openId) {
        return contactService.findContactList(openId);
    }

    /**
     * 删除联系人
     *
     * @param openId
     * @return
     */
    @PostMapping("/delContact")
    public ResultVO delContact(@RequestParam("recordId") String recordId, @RequestParam("openId") String openId) {
        return contactService.delContact(recordId, openId);
    }


}

